/*
 * @Author: Wang WeiHao
 * @Date: 2024-09-26 14:42:55
 * @LastEditors: Wang WeiHao
 * @LastEditTime: 2024-10-15 11:39:11
 * @Description:
 * @FilePath: \geo-base-dm\src\utils\tsTools.ts
 */
import type { Tree } from "@/api/ai-processing/types";
/* 根据配置项翻译  */
export function translateInterpreType(label: string | null): string {
	// 根据 label: 'water'  和  lable ：'water,road' 判断翻译结果
	// water,road 被翻译成 水体,道路
	if (!label) return "未知类型";
	if (label.indexOf(",") > -1) {
		const labels = label.split(",");
		let labelStr = "";
		for (const iterator of labels) {
			labelStr += BASE_CONFIG["vectorColor"][iterator]["label"] + ",";
		}
		labelStr = labelStr.substring(0, labelStr.length - 1);
		return labelStr;
	}
	const color = BASE_CONFIG["vectorColor"][label].label;
	return color;
}
export function translateInterpreTypelegend(label: string | null): string {
	// 根据 label: 'water'  和  lable ：'water,road' 判断翻译结果
	// water,road 被翻译成 水体,道路
	if (!label) return "未知类型";
	if (label.indexOf(",") > -1) {
		const labels = label.split(",");
		let labelStr = "";
		for (const iterator of labels) {
			labelStr += BASE_CONFIG["vectorlegend"][iterator]["label"] + ",";
		}
		labelStr = labelStr.substring(0, labelStr.length - 1);
		return labelStr;
	}
	const color = BASE_CONFIG["vectorlegend"][label].label;
	return color;
}
/* 获取文件名 */
export function getFileName(path: string): string {
	// 将 X:\\f2ee87f4-80af-4509-867b-d7a883540864\\20231222.tif 变成 20231222.tif
	const pathArr = path.split("\\");
	const fileName = pathArr[pathArr.length - 1];
	return fileName;
}
/* 处理原文件树结构数据 */
export function handleTreeData(data: Tree): Tree {
	// 将原始数据
	// data.children[0].name = "公共数据";
	// if (data.children[1]) {
	// 	data.children[1].name = "我的数据";
	// }
	return data;
}
